#include <iostream>
#include "StaticList.h"
#include "DynamicList.h"

using namespace DTLib;
using namespace std;

void StaticListDemo()
{
	cout << "StaticList begin." << endl;

    StaticList<int, 5> sl;

    for (int i = 0; i < sl.capacity(); i++)
    {
        sl.insert(0, i);
    }

    for (int i = 0; i < sl.capacity(); i++)
    {
        cout << "i = " << sl[i] << endl;
    }

    cout << "StaticList end." << endl;
}

void DynamicListDemo()
{
    cout << "DynamicList begin." << endl;
	
	DynamicList<int> l(5);

	for(int i = 0; i < l.capacity(); i++)
	{
		l.insert(0, i);
	}

	for(int i = 0; i < l.length(); i++)
	{
		cout << l[i] << endl;}l[0] *= l[0];

	for(int i = 0; i < l.length(); i++)
	{
		cout << l[i] << endl;
}

	try
	{
		l[5] = 5;
	}
	catch(const Exception& e)
	{
		cout << e.message() << endl;
		cout << e.location() << endl;

		l.resize(10);
		l.insert(5, 50);
	}

	l[5] = 5;

	for(int i=0; i<l.length(); i++)
	{
		cout << l[i] << endl;
	}

	l.resize(3);

	for(int i=0; i<l.length(); i++)
	{
		cout << l[i] << endl;
	}
		
    cout << "DynamicList end." << endl;
}


int main()
{
	StaticListDemo();
	
	DynamicListDemo();

    return 0;
}
